﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace wesiGestClinica.Controles
{
    public partial class UCCalendario : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MaskedEditExtender1.CultureName = "es-PE";
            CalendarExtender1.Format = "dd/MM/yyyy";
        }
        public DateTime? value
        {
            get
            {
                if (this.txtFecha.Text != string.Empty)
                    return DateTime.Parse(this.txtFecha.Text);
                else
                    return DateTime.MinValue;
            
            }
            set
            {
                if (value.HasValue)
                    this.txtFecha.Text = value.Value.ToShortDateString();
                else
                    this.txtFecha.Text = string.Empty;
            }
        }


        public string Texto
        {
            set
            {
                this.txtFecha.Text = value;
            }

            get
            {
                return this.txtFecha.Text;
            }
        }
        public TextBox TextoFecha
        {
            get { return txtFecha; }
            set { txtFecha = value; }
        }
        public bool Enabled
        {
            set
            {

                this.txtFecha.Enabled = value;
                this.imgFec.Disabled = !value;
                this.imgFec.Src = (value) ? "../Image/Calendar.gif" : "../Image/DisableCalendar.gif";
            }
            get
            {
                return this.txtFecha.Enabled;
            }
        }
    }
}